package com.yb.xczx.cloud.auth.controller;

import com.yb.core.model.XczxLoginUser;
import com.yb.core.model.XczxResult;
import com.yb.xczx.cloud.auth.service.ILoginEntryService;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.servlet.ModelAndView;

/**
 * Copyright (C), 2022-2023, 姚兵
 * Author: 32210
 * Date: 2023/5/20 16:19
 * FileName: LoginController
 * Description:
 */

@RestController
@Slf4j
public class LoginEntryController {

    @Autowired
    ILoginEntryService loginEntryService;

    @PostMapping("/login/code")
    public XczxResult code(@RequestBody XczxLoginUser xczxLoginUser){
        return loginEntryService.code(xczxLoginUser);
    }


    @GetMapping("/login.html")
    public ModelAndView loginPage(@RequestParam(required = false) String targetUrlKey){
        ModelAndView mav = new ModelAndView();
        mav.addObject("targetUrlKey",targetUrlKey);
        mav.setViewName("login");
        return mav;
    }
}
